package com.CST.controller;


import com.CST.annotation.*;
import com.CST.common.api.Response;
import com.CST.common.api.ResultObject;
import com.CST.common.constant.*;
import com.CST.dto.DateDTO;
import com.CST.entity.*;
import com.CST.service.*;
import com.CST.vo.ReportBaseSalaryVO;
import com.CST.vo.ReportSalaryDetailVO;
import io.swagger.annotations.*;

import java.util.*;

import oracle.jdbc.proxy.annotation.Post;
import org.springframework.beans.factory.annotation.*;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ly
 * @since 2022-04-20
 */
@Api(tags = {"薪酬-人员经费明细"})
@RestController
@RequestMapping("/baseSalary2021")

public class BaseSalaryController {
    
    @Autowired
    private IBaseSalaryService baseSalaryService;
    
    @PostMapping("/insertBaseSalary")
    @ApiOperation("采集人员经费明细")
    public Response insertBaseSalary(@RequestBody DateDTO dateDTO){
        baseSalaryService.insertBaseSalary(dateDTO);
        return Response.success("采集成功");
    }
    
    @PostMapping("/listSalaryWithExtraByPDeptCode/{pDeptCode}")
    @ApiOperation("根据父级科室获取子科室的人员经费详情（人员经费1级），经费来源分组，包括薪酬和绩效")
    public ResultObject listSalaryWithExtraByPDeptCode(@RequestBody DateDTO dateDTO, @PathVariable String pDeptCode){
        List list = baseSalaryService.listSalaryWithExtraByPDeptCode(dateDTO, pDeptCode);
        return ResultObject.successReturn(list);
    }
    
    @PostMapping("/listSalaryByPDeptCodeAndDeptCode/{pDeptCode}/{deptCode}")
    @ApiOperation("人员经费二级明细，点击子科室，根据父级科室+子科室编号获取人员经费明细（根据人员）")
    public ResultObject listSalaryByPDeptCodeAndDeptCode(@RequestBody DateDTO dateDTO, @PathVariable String pDeptCode, @PathVariable String deptCode){
        List<BaseSalary> baseSalaryList = baseSalaryService.listSalaryByPDeptCodeAndDeptCode(dateDTO, pDeptCode, deptCode);
        return ResultObject.successReturn(baseSalaryList);
    }

//    @PostMapping("/listSalaryByDeptAndAccId/{pDeptCode}/{deptCode}/{accId}")
//    @ApiOperation("人员经费二级明细，点击账套，根据父级科室+子科室+账套显示人员经费明细（根据成本项目）")
//    public ResultObject listSalaryByDeptAndAccId(@RequestBody DateDTO dateDTO, @PathVariable String pDeptCode, @PathVariable String deptCode, @PathVariable String accId){
//        List<ReportBaseSalaryVO> list = baseSalaryService.listSalaryByDeptAndAccId(dateDTO, pDeptCode, deptCode, accId);
//        return ResultObject.successReturn(list);
//    }
    
    @PostMapping("/listSalaryDetailByDateAndPDeptAndDept/{pDeptCode}/{deptCode}")
    @ApiOperation("人员经费二级明细，点击薪酬总额，根据父级科室+子科室+成本项目显示人员经费")
    public ResultObject listSalaryDetailByDateAndPDeptAndDept(@RequestBody DateDTO dateDTO, @PathVariable String pDeptCode, @PathVariable String deptCode){
        List<ReportSalaryDetailVO> list = baseSalaryService.listSalaryDetailByDateAndPDeptAndDept(dateDTO, pDeptCode,deptCode);
        return ResultObject.successReturn(list);
    }

    @PostMapping("/listSalaryWithExtraByDeptCode/{deptCode}")
    @ApiOperation("成本分析人员经费下撰")
    public ResultObject listSalaryWithExtraByDeptCode(@RequestBody DateDTO dateDTO, @PathVariable String deptCode){
        List list = baseSalaryService.listSalaryWithExtraBydeptCode(dateDTO, deptCode);
        return ResultObject.successReturn(list);
    }
    
    @PostMapping("/listPerformanceDetailByDateAndPDeptAndDept/{pDeptCode}/{deptCode}")
    @ApiOperation("人员经费二级明细，点击绩效总额，根据父级科室+子科室+成本项目显示")
    public ResultObject listPerformanceDetailByDateAndPDeptAndDept(@RequestBody DateDTO dateDTO, @PathVariable String pDeptCode, @PathVariable String deptCode){
        List<ReportBaseSalaryVO> list = baseSalaryService.listPerformanceDetailByDateAndPDeptAndDept(dateDTO,pDeptCode,deptCode);
        return ResultObject.successReturn(list);
    }
    

}

